package com.ruoyi.project.check.controller;


import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.check.domain.CheckMode;
import com.ruoyi.project.check.service.ICheckModeService;
import com.ruoyi.project.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/check/result")
public class CheckResultController extends BaseController {
    @Autowired
    private ICheckModeService checkModeService;

    /**
     * 根据检查单号查询信息
     */
    @PreAuthorize("@ss.hasPermi('check:result:index')")
    @PostMapping("list")
    public TableDataInfo list(String checkCode)
    {
        List<CheckMode> list = checkModeService.selCheckResultSrvice(checkCode);
        return getDataTable(list);
    }


    //@PreAuthorize("@ss.hasPermi('check:result:index')")
   // @Log(title = "检查管理", businessType = BusinessType.INSERT)
    @GetMapping("edit")
    public AjaxResult startSuccess(@PathVariable String checkCode)
    {
        return toAjax(checkModeService.updateFlag(checkCode));
    }

    /**
     * 录入图片信息
     */
    @PreAuthorize("@ss.hasPermi('check:result:index')")
    @PostMapping("/edit2/{checkCode}/{fileSite}")
    public AjaxResult query(@RequestBody CheckMode checkMode,@PathVariable String fileSite ,@PathVariable String checkCode)
    {
        //System.out.println(checkMode.getCheckResult()+"==."+fileSite+"---"+checkCode);
        return toAjax(checkModeService.updateCheckFile(checkMode.getCheckResult(),fileSite,checkCode));
    }


}
